<?php

namespace app\model\school;

use app\BaseModel;
use app\model\RatingScaleModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 心理学堂-课程-章节
 */
class SchoolCourseChapterModel extends BaseModel
{
    protected $name = 'school_course_chapter';

    /**
     * 评论
     * @return HasMany
     */
    public function chapterComment(): HasMany
    {
        return $this->hasMany(SchoolCourseChapterCommentModel::class, 'chapter_id');
    }

    /**
     * 量表
     * @return BelongsTo
     */
    public function RatingScale(): BelongsTo
    {
        return $this->belongsTo(RatingScaleModel::class,'rating_scale_id')->bind([
            'rating_scale_name' => 'name',
            'rating_scale_cover' => 'cover',
        ]);
    }

    /**
     * 课程
     * @return BelongsTo
     */
    public function course(): BelongsTo
    {
        return $this->belongsTo(SchoolCourseModel::class,'course_id')->bind([
            'course_name' => 'name',
            'course_cover' => 'cover'
        ]);
    }
}